package com.ruoyi.crm.controller.record;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.crm.domain.vo.ClueTrackRecordVO;
import com.ruoyi.crm.domain.vo.MongoClueRecordVO;
import com.ruoyi.crm.service.ClueTrackRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * @author mr.huang [jie88888822@163.com]
 * @devTime 2022-06-21
 */
@Slf4j
@RequestMapping("/clues")
@RestController("clueRecordController")
public class ClueRecordController extends BaseController {
	@Resource
	private ClueTrackRecordService clueTrackRecordService;

	/**
	 * 根据线索ID查询线索操作记录
	 * @param clueId
	 * @return
	 */
	@GetMapping("/record/list")
	public TableDataInfo recordList(Long clueId){
		List<MongoClueRecordVO> voByClueId =
				clueTrackRecordService.findClueTrackRecordVoByClueId(clueId);
		log.info("voByClueId：{}",voByClueId);
		return getDataTable(voByClueId);
	}

	/**
	 * 线索跟进
	 * @param clueTrackRecordVo
	 * @return
	 */
	@PostMapping("/record")
	public AjaxResult addClueRecord(@RequestBody ClueTrackRecordVO clueTrackRecordVo){
		clueTrackRecordService.addClueTrackRecordVo(clueTrackRecordVo);
		return AjaxResult.success();
	}
}
